/*
* Portuguese eID Card API .NET Wrapper
*
* Written by Fernando Nunes (fernando.nunes@devscope.net)
* Copyright (c) 2009 DevScope Information Systems
*
* This library is free software; you can redistribute it and/or 
* modify it under the terms of the GNU Lesser General Public 
* License as published by the Free Software Foundation; either 
* version 2.1 of the License, or (at your option) any later version. 
* 
* This library is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
* Lesser General Public License for more details. 
* 
* You should have received a copy of the GNU Lesser General Public 
* License along with this library; if not, write to the Free Software 
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 
*/

#pragma once
#include "Stdafx.h"
#include "ProxyInfo.h"
#include "Interop.h"

using namespace System;
using namespace DevScope::CartaoDeCidadao;

ProxyInfo::ProxyInfo()
{
	this->Server = String::Empty;
	this->Port = 0;
	this->Username = String::Empty;
	this->Password = String::Empty;
}

ProxyInfo::ProxyInfo(String^ server, UInt32 port)
{
	this->Server = server;
	this->Port = port;
	this->Username = String::Empty;
	this->Password = String::Empty;
}

ProxyInfo::ProxyInfo(String^ server, UInt32 port, String^ username, String^ password)
{
	this->Server = server;
	this->Port = port;
	this->Username = username;
	this->Password = password;
}

ProxyInfo::ProxyInfo(const tProxyInfo& i)
{
	this->Server = Interop::CStrToNetStr((char*)i.csProxy);
	this->Port = i.uiPort;
	this->Username = Interop::CStrToNetStr((char*)i.csUserName);
	this->Password = Interop::CStrToNetStr((char*)i.csPassword);
}

tProxyInfo ProxyInfo::ToUnmanaged()
{
	tProxyInfo proxyInfo = tProxyInfo();
	proxyInfo.uiPort = this->Port;
	Interop::copyNetToStr(this->Server, (char*)proxyInfo.csProxy);
	Interop::copyNetToStr(this->Username, (char*)proxyInfo.csUserName);
	Interop::copyNetToStr(this->Password, (char*)proxyInfo.csPassword);
	return proxyInfo;
}